home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / term34Source.lha / termOldConfig.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  15KB  |  671 lines

  1. /*
  2. **    termOldConfig.c
  3. **
  4. **    Old configuration processing routines
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. struct OldSerialSettings
  13. {
  14.     ULONG    BaudRate;
  15.     ULONG    BreakLength;
  16.     ULONG    SerialBufferSize;
  17.  
  18.     UBYTE    SerialDevice[256];
  19.     LONG    UnitNumber;
  20.  
  21.     BYTE    BitsPerChar;
  22.     BYTE    Parity;
  23.     BYTE    StopBits;
  24.     BYTE    HandshakingProtocol;
  25.     BYTE    Duplex;
  26.  
  27.     BYTE    xONxOFF;
  28.     BYTE    HighSpeed;
  29.     BYTE    Shared;
  30.     BYTE    StripBit8;
  31.     BYTE    CheckCarrier;
  32.     BYTE    PassThrough;
  33. };
  34.  
  35. struct OldModemSettings
  36. {
  37.     UBYTE    ModemInit[80];
  38.     UBYTE     ModemExit[80];
  39.     UBYTE     ModemHangup[80];
  40.     UBYTE    DialPrefix[80];
  41.     UBYTE    DialSuffix[80];
  42.  
  43.     UBYTE    NoCarrier[16];
  44.     UBYTE    NoDialTone[16];
  45.     UBYTE    Connect[16];
  46.     UBYTE    Voice[16];
  47.     UBYTE    Ring[16];
  48.     UBYTE    Busy[16];
  49.  
  50.     LONG    RedialDelay;
  51.     LONG    DialRetries;
  52.     LONG    DialTimeout;
  53.     BYTE    ConnectAutoBaud;
  54.     BYTE    DropDTR;
  55. };
  56.  
  57. struct OldCommandSettings
  58. {
  59.     UBYTE    StartupMacro[256];
  60.     UBYTE    LogoffMacro[256];
  61.     UBYTE    UploadMacro[256];
  62.     UBYTE    DownloadMacro[256];
  63. };
  64.  
  65. struct OldScreenSettings
  66. {
  67.     ULONG    DisplayMode;
  68.     WORD    ColourMode;
  69.     UWORD    Colours[16];
  70.     UBYTE    FontName[256];
  71.     WORD    FontHeight;
  72.  
  73.     BYTE    MakeScreenPublic;
  74.     BYTE    ShanghaiWindows;
  75.  
  76.     BYTE    Blinking;
  77.     BYTE    FasterLayout;
  78.     BYTE    TitleBar;
  79.     BYTE    StatusLine;
  80. };
  81.  
  82. struct OldTerminalSettings
  83. {
  84.     BYTE    BellMode;
  85.     BYTE    AlertMode;
  86.     BYTE    EmulationMode;
  87.     BYTE    FontMode;
  88.  
  89.     BYTE    SendCR;
  90.     BYTE    SendLF;
  91.     BYTE    ReceiveCR;
  92.     BYTE    ReceiveLF;
  93.  
  94.     UWORD    NumColumns,
  95.         NumLines;
  96.  
  97.     UBYTE    KeyMapFileName[256];
  98.     UBYTE    EmulationFileName[256];
  99.     UBYTE    BeepFileName[256];
  100.  
  101.     UBYTE    TextFontName[256];
  102.     WORD    TextFontHeight;
  103. };
  104.  
  105. struct OldPathSettings
  106. {
  107.     UBYTE    ASCIIUploadPath[256];
  108.     UBYTE    ASCIIDownloadPath[256];
  109.  
  110.     UBYTE    TextUploadPath[256];
  111.     UBYTE    TextDownloadPath[256];
  112.  
  113.     UBYTE    BinaryUploadPath[256];
  114.     UBYTE    BinaryDownloadPath[256];
  115.  
  116.     UBYTE    DefaultStorage[256];
  117.  
  118.     UBYTE    Editor[256];
  119. };
  120.  
  121. struct OldMiscSettings
  122. {
  123.     BYTE    Priority;
  124.     BYTE    BackupConfig;
  125.  
  126.     BYTE    OpenFastMacroPanel;
  127.     BYTE    ReleaseDevice;
  128.  
  129.     BYTE    TransferServer;
  130.     BYTE    EmulationServer;
  131.  
  132.     BYTE    OverridePath;
  133.     BYTE    AutoUpload;
  134.     BYTE    SetArchivedBit;
  135.     BYTE    IdentifyFiles;
  136. };
  137.  
  138. struct OldClipSettings
  139. {
  140.     WORD    ClipboardUnit;
  141.  
  142.     WORD    LineDelay,
  143.         CharDelay;
  144.  
  145.     UBYTE    InsertPrefix[80];
  146.     UBYTE    InsertSuffix[80];
  147. };
  148.  
  149. struct OldCaptureSettings
  150. {
  151.     BYTE    LogActions;
  152.     BYTE    LogCall;
  153.     UBYTE    LogFileName[256];
  154.  
  155.     LONG    MaxBufferSize;
  156.     BYTE    BufferEnabled;
  157.  
  158.     BYTE    ConnectAutoCapture;
  159.     BYTE    CaptureFilterMode;
  160.     UBYTE    CapturePath[256];
  161. };
  162.  
  163. struct OldFileSettings
  164. {
  165.     UBYTE    ProtocolFileName[256];
  166.     UBYTE    TranslationFileName[256];
  167.     UBYTE    MacroFileName[256];
  168.     UBYTE    CursorFileName[256];
  169.     UBYTE    FastMacroFileName[256];
  170. };
  171.  
  172. struct OldEmulationSettings
  173. {
  174.     BYTE    CursorMode;
  175.     BYTE    NumericMode;
  176.  
  177.     BYTE    CursorWrap;
  178.     BYTE    LineWrap;
  179.  
  180.     BYTE    InsertMode;
  181.     BYTE    NewLineMode;
  182.  
  183.     BYTE    FontScale;
  184.     BYTE    ScrollMode;
  185.     BYTE    DestructiveBackspace;
  186.     BYTE    SwapBSDelete;
  187.     BYTE    PrinterEnabled;
  188.     BYTE    Pad;
  189.  
  190.     UBYTE    AnswerBack[80];
  191. };
  192.  
  193. struct OldConfiguration
  194. {
  195.     struct OldSerialSettings    SerialConfig;
  196.     struct OldModemSettings        ModemConfig;
  197.     struct OldScreenSettings    ScreenConfig;
  198.     struct OldTerminalSettings    TerminalConfig;
  199.     struct OldEmulationSettings    EmulationConfig;
  200.     struct OldClipSettings        ClipConfig;
  201.     struct OldCaptureSettings    CaptureConfig;
  202.     struct OldCommandSettings    CommandConfig;
  203.     struct OldMiscSettings        MiscConfig;
  204.     struct OldPathSettings        PathConfig;
  205.     struct OldFileSettings        FileConfig;
  206. };
  207.  
  208. struct OldPhoneHeader
  209. {
  210.     UBYTE    Name[40],        /* BBS name. */
  211.         Number[60],        /* Phone number. */
  212.         Comment[40];        /* Comment. */
  213.  
  214.     UBYTE    UserName[30],        /* User name for this BSS. */
  215.         Password[30];        /* Password for user name. */
  216. };
  217.  
  218.     /* ConvertHeader():
  219.      *
  220.      *    Convert old style phone book header to new style
  221.      *    phone book header.
  222.      */
  223.  
  224. STATIC VOID
  225. ConvertHeader(struct OldPhoneHeader *OldHeader,struct PhoneHeader *NewHeader)
  226. {
  227.     strcpy(NewHeader -> Name,    OldHeader -> Name);
  228.     strcpy(NewHeader -> Number,    OldHeader -> Number);
  229.     strcpy(NewHeader -> Comment,    OldHeader -> Comment);
  230.  
  231.     strcpy(NewHeader -> UserName,    OldHeader -> UserName);
  232.     strcpy(NewHeader -> Password,    OldHeader -> Password);
  233. }
  234.  
  235.     /* ConvertConfig():
  236.      *
  237.      *    Convert old style configuration to new style configuration.
  238.      */
  239.  
  240. STATIC BYTE
  241. ConvertConfig(struct OldConfiguration *OldConfig,struct Configuration *NewConfig)
  242. {
  243.     if(CreateConfigEntry(NewConfig,PREF_SERIAL))
  244.     {
  245.         ResetConfigEntry(NewConfig,PREF_SERIAL,FALSE);
  246.  
  247.         memcpy(NewConfig -> SerialConfig,&OldConfig -> SerialConfig,MIN(sizeof(struct SerialSettings),sizeof(struct OldSerialSettings)));
  248.     }
  249.     else
  250.         return(FALSE);
  251.  
  252.     if(CreateConfigEntry(NewConfig,PREF_MODEM))
  253.     {
  254.         ResetConfigEntry(NewConfig,PREF_MODEM,FALSE);
  255.  
  256.         memcpy(NewConfig -> ModemConfig,&OldConfig -> ModemConfig,MIN(sizeof(struct ModemSettings),sizeof(struct OldModemSettings)));
  257.     }
  258.     else
  259.         return(FALSE);
  260.  
  261.     if(CreateConfigEntry(NewConfig,PREF_COMMAND))
  262.     {
  263.         ResetConfigEntry(NewConfig,PREF_COMMAND,FALSE);
  264.  
  265.         memcpy(NewConfig -> CommandConfig,&OldConfig -> CommandConfig,MIN(sizeof(struct CommandSettings),sizeof(struct OldCommandSettings)));
  266.     }
  267.     else
  268.         return(FALSE);
  269.  
  270.     if(CreateConfigEntry(NewConfig,PREF_SCREEN))
  271.     {
  272.         ResetConfigEntry(NewConfig,PREF_SCREEN,FALSE);
  273.  
  274.         memcpy(NewConfig -> ScreenConfig,&OldConfig -> ScreenConfig,MIN(sizeof(struct ScreenSettings),sizeof(struct OldScreenSettings)));
  275.     }
  276.     else
  277.         return(FALSE);
  278.  
  279.     if(CreateConfigEntry(NewConfig,PREF_TERMINAL))
  280.     {
  281.         ResetConfigEntry(NewConfig,PREF_TERMINAL,FALSE);
  282.  
  283.         memcpy(NewConfig -> TerminalConfig,&OldConfig -> TerminalConfig,MIN(sizeof(struct TerminalSettings),sizeof(struct OldTerminalSettings)));
  284.     }
  285.     else
  286.         return(FALSE);
  287.  
  288.     if(CreateConfigEntry(NewConfig,PREF_PATH))
  289.     {
  290.         ResetConfigEntry(NewConfig,PREF_PATH,FALSE);
  291.  
  292.         memcpy(NewConfig -> PathConfig,&OldConfig -> PathConfig,MIN(sizeof(struct PathSettings),sizeof(struct OldPathSettings)));
  293.     }
  294.     else
  295.         return(FALSE);
  296.  
  297.     if(CreateConfigEntry(NewConfig,PREF_MISC))
  298.     {
  299.         ResetConfigEntry(NewConfig,PREF_MISC,FALSE);
  300.  
  301.         memcpy(NewConfig -> MiscConfig,&OldConfig -> MiscConfig,MIN(sizeof(struct MiscSettings),sizeof(struct OldMiscSettings)));
  302.     }
  303.     else
  304.         return(FALSE);
  305.  
  306.     if(CreateConfigEntry(NewConfig,PREF_CLIP))
  307.     {
  308.         ResetConfigEntry(NewConfig,PREF_CLIP,FALSE);
  309.  
  310.         memcpy(NewConfig -> ClipConfig,&OldConfig -> ClipConfig,MIN(sizeof(struct ClipSettings),sizeof(struct OldClipSettings)));
  311.     }
  312.     else
  313.         return(FALSE);
  314.  
  315.     if(CreateConfigEntry(NewConfig,PREF_CAPTURE))
  316.     {
  317.         ResetConfigEntry(NewConfig,PREF_CAPTURE,FALSE);
  318.  
  319.         memcpy(NewConfig -> CaptureConfig,&OldConfig -> CaptureConfig,MIN(sizeof(struct CaptureSettings),sizeof(struct OldCaptureSettings)));
  320.  
  321.         strcpy(NewConfig -> CaptureConfig -> CallLogFileName,NewConfig -> CaptureConfig -> LogFileName);
  322.  
  323.         AddPart(NewConfig -> CaptureConfig -> CallLogFileName,"term-call.log",MAX_FILENAME_LENGTH);
  324.     }
  325.     else
  326.         return(FALSE);
  327.  
  328.     if(CreateConfigEntry(NewConfig,PREF_FILE))
  329.     {
  330.         ResetConfigEntry(NewConfig,PREF_FILE,FALSE);
  331.  
  332.         memcpy(NewConfig -> FileConfig,&OldConfig -> FileConfig,MIN(sizeof(struct FileSettings),sizeof(struct OldFileSettings)));
  333.     }
  334.     else
  335.         return(FALSE);
  336.  
  337.     if(CreateConfigEntry(NewConfig,PREF_EMULATION))
  338.     {
  339.         ResetConfigEntry(NewConfig,PREF_EMULATION,FALSE);
  340.  
  341.         memcpy(NewConfig -> EmulationConfig,&OldConfig -> EmulationConfig,MIN(sizeof(struct EmulationSettings),sizeof(struct OldEmulationSettings)));
  342.     }
  343.     else
  344.         return(FALSE);
  345.  
  346.     return(TRUE);
  347. }
  348.  
  349.     /* LoadOldPhonebook(STRPTR Name):
  350.      *
  351.      *    Restore a phone book from a disk file.
  352.      */
  353.  
  354. BYTE
  355. LoadOldPhonebook(STRPTR Name)
  356. {
  357.     STATIC ULONG Stops[6 * 2] =
  358.     {
  359.         ID_TERM,ID_VERS,
  360.         ID_TERM,ID_DIAL,
  361.         ID_TERM,ID_PREF,
  362.         ID_TERM,ID_DATE,
  363.         ID_TERM,ID_PHON,
  364.         ID_TERM,ID_PSWD
  365.     };
  366.  
  367.     struct PhoneEntry    **PrivatePhonebook;
  368.     LONG             PrivatePhoneSize = 0;
  369.     LONG             Size = 0,Count = 0,Last = -1;
  370.     struct IFFHandle    *Handle;
  371.     BYTE             Success = FALSE;
  372.     struct ContextNode    *Chunk;
  373.     BYTE             LastHadTime    = TRUE,
  374.                  HadPassword    = FALSE;
  375.     struct TimeDateNode    *TimeDateNode;
  376.     struct OldConfiguration    *OldConfig;
  377.     struct OldPhoneHeader    *OldHeader;
  378.  
  379.     if(OldConfig = (struct OldConfiguration *)AllocVec(sizeof(struct OldConfiguration) + sizeof(struct OldPhoneHeader),MEMF_ANY))
  380.     {
  381.         OldHeader = (struct OldPhoneHeader *)(OldConfig + 1);
  382.  
  383.         if(Handle = AllocIFF())
  384.         {
  385.             if(Handle -> iff_Stream = Open(Name,MODE_OLDFILE))
  386.             {
  387.                 InitIFFasDOS(Handle);
  388.  
  389.                 if(!OpenIFF(Handle,IFFF_READ))
  390.                 {
  391.                     if(!StopChunks(Handle,Stops,6))
  392.                     {
  393.                         while(!ParseIFF(Handle,IFFPARSE_SCAN))
  394.                         {
  395.                             Chunk = CurrentChunk(Handle);
  396.  
  397.                             if(Chunk -> cn_ID == ID_VERS)
  398.                             {
  399.                                 struct TermInfo TermInfo;
  400.  
  401.                                 if(ReadChunkBytes(Handle,&TermInfo,sizeof(struct TermInfo)) == sizeof(struct TermInfo))
  402.                                 {
  403.                                     if(TermInfo . Version != 2 || TermInfo . Revision != 4)
  404.                                         break;
  405.                                 }
  406.                                 else
  407.                                     break;
  408.                             }
  409.  
  410.                             if(Chunk -> cn_ID == ID_PSWD)
  411.                             {
  412.                                 UBYTE DummyBuffer[20];
  413.  
  414.                                 HadPassword = TRUE;
  415.  
  416.                                 if(ReadChunkBytes(Handle,DummyBuffer,20) == 20)
  417.                                 {
  418.                                     if(PhonePasswordUsed)
  419.                                     {
  420.                                         if(!memcmp(PhonePassword,DummyBuffer,20))
  421.                                             continue;
  422.                                     }
  423.  
  424.                                     memset(SharedBuffer,0,21);
  425.  
  426.                                     if(GetString(FALSE,TRUE,21,LocaleString(MSG_PHONEPANEL_PLEASE_ENTER_PASSWORD_TXT),SharedBuffer))
  427.                                     {
  428.                                         UBYTE AnotherBuffer[20];
  429.  
  430.                                         Encrypt(SharedBuffer,20,AnotherBuffer,SharedBuffer,strlen(SharedBuffer));
  431.  
  432.                                         if(!memcmp(DummyBuffer,AnotherBuffer,20))
  433.                                         {
  434.                                             memcpy(PhonePassword,DummyBuffer,20);
  435.  
  436.                                             PhonePasswordUsed = TRUE;
  437.  
  438.                                             continue;
  439.                                         }
  440.                                         else
  441.                                         {
  442.                                             MyEasyRequest(Window,LocaleString(MSG_TERMPHONE_WRONG_PASSWORD_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),Name);
  443.  
  444.                                             break;
  445.                                         }
  446.                                     }
  447.                                     else
  448.                                         break;
  449.                                 }
  450.                                 else
  451.                                     break;
  452.                             }
  453.  
  454.                             if(Chunk -> cn_ID == ID_DIAL)
  455.                             {
  456.                                 if(ReadChunkBytes(Handle,&Size,sizeof(LONG)) == sizeof(LONG))
  457.                                 {
  458.                                     if(!(PrivatePhonebook = CreatePhonebook(Size,&PrivatePhoneSize,TRUE)))
  459.                                         break;
  460.                                 }
  461.                                 else
  462.                                     break;
  463.                             }
  464.  
  465.                             if(Chunk -> cn_ID == ID_PHON)
  466.                             {
  467.                                 WORD Size = MIN(sizeof(struct OldPhoneHeader),Chunk -> cn_Size);
  468.  
  469.                                 if(ReadChunkBytes(Handle,OldHeader,Size) == Size)
  470.                                 {
  471.                                     if(PhonePasswordUsed)
  472.                                         Decrypt((UBYTE *)OldHeader,Size,(UBYTE *)OldHeader,PhonePassword,20);
  473.                                 }
  474.                                 else
  475.                                     break;
  476.                             }
  477.  
  478.                             if(Chunk -> cn_ID == ID_PREF)
  479.                             {
  480.                                 if(Last != -1)
  481.                                 {
  482.                                     if(!LastHadTime)
  483.                                     {
  484.                                         if(TimeDateNode = CreateTimeDateNode(-1,-1,"",2))
  485.                                             AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  486.                                     }
  487.                                 }
  488.  
  489.                                 if(Size && Count < Size)
  490.                                 {
  491.                                     WORD LastSize = MIN(Chunk -> cn_Size,sizeof(struct OldConfiguration));
  492.  
  493.                                     PhonePasswordUsed = HadPassword;
  494.  
  495.                                     if(ReadChunkBytes(Handle,OldConfig,LastSize) == LastSize)
  496.                                     {
  497.                                         if(PhonePasswordUsed)
  498.                                             Decrypt((UBYTE *)OldConfig,LastSize,(UBYTE *)OldConfig,PhonePassword,20);
  499.  
  500.                                         if(ConvertConfig(OldConfig,PrivatePhonebook[Count] -> Config))
  501.                                         {
  502.                                             ConvertHeader(OldHeader,PrivatePhonebook[Count] -> Header);
  503.  
  504.                                             Last = Count;
  505.  
  506.                                             PrivatePhonebook[Count] -> Count = -1;
  507.  
  508.                                             Count++;
  509.  
  510.                                             LastHadTime = FALSE;
  511.                                         }
  512.                                         else
  513.                                         {
  514.                                             if(Count)
  515.                                                 Size = Count - 1;
  516.                                             else
  517.                                                 Size = 0;
  518.  
  519.                                             break;
  520.                                         }
  521.                                     }
  522.                                     else
  523.                                     {
  524.                                         if(Count)
  525.                                             Size = Count - 1;
  526.                                         else
  527.                                             Size = 0;
  528.  
  529.                                         break;
  530.                                     }
  531.                                 }
  532.                             }
  533.  
  534.                             if(Chunk -> cn_ID == ID_DATE)
  535.                             {
  536.                                 if(Last != -1)
  537.                                 {
  538.                                     WORD Count = (Chunk -> cn_Size - sizeof(struct TimeDateHeader)) / sizeof(struct TimeDate);
  539.  
  540.                                     if(TimeDateNode = CreateTimeDateNode(-1,-1,"",Count))
  541.                                     {
  542.                                         if(ReadChunkBytes(Handle,&TimeDateNode -> Header,sizeof(struct TimeDateHeader)) == sizeof(struct TimeDateHeader))
  543.                                         {
  544.                                             if(ReadChunkBytes(Handle,TimeDateNode -> Table,sizeof(struct TimeDate) * Count) == sizeof(struct TimeDate) * Count)
  545.                                             {
  546.                                                 AdaptTimeDateNode(TimeDateNode);
  547.  
  548.                                                 AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  549.  
  550.                                                 LastHadTime = TRUE;
  551.                                             }
  552.                                             else
  553.                                                 FreeTimeDateNode(TimeDateNode);
  554.                                         }
  555.                                         else
  556.                                             FreeTimeDateNode(TimeDateNode);
  557.                                     }
  558.                                 }
  559.                             }
  560.                         }
  561.  
  562.                         if(Size)
  563.                         {
  564.                             if(!LastHadTime && Last != -1)
  565.                             {
  566.                                 if(TimeDateNode = CreateTimeDateNode(-1,-1,"",2))
  567.                                     AddTail((struct List *)&PrivatePhonebook[Last] -> TimeDateList,&TimeDateNode -> VanillaNode);
  568.                             }
  569.  
  570.                             if(Phonebook)
  571.                                 DeletePhonebook(Phonebook,PhoneSize,TRUE);
  572.  
  573.                             Phonebook = PrivatePhonebook;
  574.                             PhoneSize = PrivatePhoneSize;
  575.  
  576.                             NumPhoneEntries = Size;
  577.  
  578.                             Success = TRUE;
  579.                         }
  580.                         else
  581.                         {
  582.                             if(PrivatePhoneSize)
  583.                             {
  584.                                 DeletePhonebook(PrivatePhonebook,PrivatePhoneSize,TRUE);
  585.  
  586.                                 Success = FALSE;
  587.                             }
  588.                         }
  589.  
  590.                         FreeDialList(TRUE);
  591.                     }
  592.  
  593.                     CloseIFF(Handle);
  594.                 }
  595.  
  596.                 Close(Handle -> iff_Stream);
  597.             }
  598.  
  599.             FreeIFF(Handle);
  600.         }
  601.  
  602.         FreeVec(OldConfig);
  603.     }
  604.  
  605.     return(Success);
  606. }
  607.  
  608.     /* ReadConfig(STRPTR Name,struct Configuration *Config):
  609.      *
  610.      *    Read the configuration file, very much the same as ReadIFFData().
  611.      */
  612.  
  613. BYTE
  614. ReadOldConfig(STRPTR Name,struct Configuration *Config)
  615. {
  616.     struct IFFHandle    *Handle;
  617.     BYTE             Success = FALSE;
  618.     struct StoredProperty    *Prop;
  619.     struct TermInfo        *TermInfo;
  620.     struct OldConfiguration    *OldConfig;
  621.  
  622.     if(OldConfig = (struct OldConfiguration *)AllocVec(sizeof(struct OldConfiguration),MEMF_ANY))
  623.     {
  624.         if(Handle = AllocIFF())
  625.         {
  626.             if(Handle -> iff_Stream = Open(Name,MODE_OLDFILE))
  627.             {
  628.                 InitIFFasDOS(Handle);
  629.  
  630.                 if(!OpenIFF(Handle,IFFF_READ))
  631.                 {
  632.                     if(!PropChunks(Handle,VersionProps,1))
  633.                     {
  634.                         if(!StopChunk(Handle,ID_TERM,ID_PREF))
  635.                         {
  636.                             if(!ParseIFF(Handle,IFFPARSE_SCAN))
  637.                             {
  638.                                 if(Prop = FindProp(Handle,ID_TERM,ID_VERS))
  639.                                 {
  640.                                     TermInfo = (struct TermInfo *)Prop -> sp_Data;
  641.  
  642.                                     if(TermInfo -> Version == 2 && TermInfo -> Revision == 4)
  643.                                     {
  644.                                         struct ContextNode *Chunk = CurrentChunk(Handle);
  645.  
  646.                                         if(ReadChunkRecords(Handle,OldConfig,MIN(Chunk -> cn_Size,sizeof(struct OldConfiguration)),1) == 1)
  647.                                         {
  648.                                             if(ConvertConfig(OldConfig,Config))
  649.                                                 Success = TRUE;
  650.                                         }
  651.                                     }
  652.                                 }
  653.                             }
  654.                         }
  655.                     }
  656.  
  657.                     CloseIFF(Handle);
  658.                 }
  659.  
  660.                 Close(Handle -> iff_Stream);
  661.             }
  662.  
  663.             FreeIFF(Handle);
  664.         }
  665.  
  666.         FreeVec(OldConfig);
  667.     }
  668.  
  669.     return(Success);
  670. }
  671.